import { Component, OnInit, Input } from '@angular/core';

import { Breadcrumb } from './breadcrumb-model';
import { Router } from '@angular/router';
@Component({
  selector: 'app-breadcrumb',
  templateUrl: './breadcrumb.component.html',
  styleUrls: ['./breadcrumb.component.css']
})
export class BreadcrumbComponent implements OnInit {

  @Input() breadcrumbInfo: Breadcrumb;

  constructor(private router: Router) { }

  ngOnInit() {
    this.lists = [
      { key: "角色管理", value: "/user/roles" },
      { key: "用户管理", value: "/user/management" },
      { key: "功能权限管理", value: "/user/privilege" },
      { key: "系统管理", value: "/system/sysconfig" },
      { key: "开放平台管理", value: "/system/terminal" },
      { key: "资源管理", value: "/product/resourcetype" },
      { key: "产品管理", value: "/product/periodical" },
      { key: "入库管理", value: "/product/storage" },
      { key: "订单管理", value: "/order/person" },
      { key: "合同管理", value: "/order/contract" },
      { key: "站点管理", value: "/gateway/site" },
      { key: "门户管理", value: "/gateway/pavmenu" }
    ];
  }
  public 
  //二级导航
  public home() {
    this.router.navigate(['home']);
  }

  public lists: any;
  public second() {
    for (let i = 0; i < this.lists.length; i++) {
      if (this.lists[i].key == this.breadcrumbInfo.secondLevel){
        this.router.navigate([this.lists[i]["value"]]);
        if(this.lists[i].key == "订单管理"){
          this.router.navigate(['/order/person'], {
            queryParams: {
              id:JSON.parse(sessionStorage.getItem('institution')).institutionId,
              status:'all'
            }
          });
        }
        //break;
      }
    }
  }
}
